/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package nl.cloudfarming.client.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Timon Veenstra
 */
@NamedQueries(
    @NamedQuery(name="findAllPLots", query="select p from Plot p")
)
@Entity
@Table(name = "PLOT")
public class Plot implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="ID")
    private long id;

    @Column(name="NAME")
    private String name;

    @Column(name="WKT" ,length=10000)
    private String WKT;

    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name = "PLOT_FILE_ID")
    private PlotFile plotFile;

  
    public long getId(){
        return id;
    }

    public String getWKT() {
        return WKT;
    }

    public void setWKT(String WKT) {
        this.WKT = WKT;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public PlotFile getPlotFile(){
        return this.plotFile;
    }

    public void setPlotFile(PlotFile plotFile){
        this.plotFile = plotFile;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Plot other = (Plot) obj;
        if (this.id != other.id) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if ((this.WKT == null) ? (other.WKT != null) : !this.WKT.equals(other.WKT)) {
            return false;
        }
        if (this.plotFile != other.plotFile && (this.plotFile == null || !this.plotFile.equals(other.plotFile))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
        hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 29 * hash + (this.WKT != null ? this.WKT.hashCode() : 0);
        hash = 29 * hash + (this.plotFile != null ? this.plotFile.hashCode() : 0);
        return hash;
    }

    

}